package com.example.mymusic.utils;


import android.content.Context;
import android.content.SharedPreferences;

import com.example.mymusic.app.MyApp;

public class Comm {
    private static final String TAG="Comm";

    public static final String FlagKey="key.Flag";

    private static SharedPreferences sp= MyApp.getInstance().getSharedPreferences("shared", Context.MODE_PRIVATE);

    public static void put(String key,Object val){
        if (val instanceof Integer){
            sp.edit().putInt(key,(Integer) val).apply();
        }else if (val instanceof String){
            sp.edit().putString(key,(String)val).apply();
        }else if (val instanceof Long){
            sp.edit().putLong(key,(Long)val).apply();
        }else if (val instanceof Boolean){
            sp.edit().putBoolean(key,(Boolean)val).apply();
        }else if (val instanceof Float){
            sp.edit().putFloat(key,(Float)val).apply();
        }else{
            sp.edit().putString(key,val.toString()).apply();
        }
    }

    public static String get(String key){
        return  sp.getString(key,"");
    }
    //要返回那个在自己写

    public static Integer getInt(String key){return  sp.getInt(key,0);}


}
